//
//  AlertHelper.swift
//  Automobile
//
//  Created by erkebulan elzhan on 9/1/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import UIKit

protocol Alertable {
    
}

extension Alertable where Self: UIViewController {
    
    func showAlert (_ title: String, _ message: String) {
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
        self.present(alert, animated: true, completion: nil)
    }
    
    func alertError (error: RequestError) {
       switch error {
           case .general:
               self.showAlert("Упс...", "Неизвестная ошибка")
           case .parameter(let message):
              self.showAlert("Упс...", message)
       }
    }
}
